@extends('admin.main')
@section('content')
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf">
                    <strong class="am-text-primary am-text-lg">后台设置</strong>
                    /
                    <strong class="am-text-primary am-text-lg">货单发布</strong>
                    {{--/ <small>H5扩展</small>--}}
                </div>
            </div>
            <hr>
            {{--@include('admin.layouts.menu')--}}
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-6">
                    <div class="am-btn-toolbar">
                        <div class="am-btn-group am-btn-group-xs">
                            <a href="{{$prefix_url}}/basic">
                                <button type="button" class="am-btn am-btn-default">
                                    <span class="am-icon-plus"></span> 新增
                                </button>
                            </a>
                            <a href="{{$prefix_url}}/clean">
                                <button type="button" class="am-btn am-btn-default">
                                    清空数据
                                </button>
                            </a>
                        </div>
                    </div>
                </div>
            </div>

            <div class="am-g">
                <div class="am-u-sm-12">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-check"><input type="checkbox" /></th>
                            <th class="table-id">ID</th>
                            <th class="table-title">货单产品</th>
                            <th class="table-type">发单公司</th>
                            <th class="table-author am-hide-sm-only">有效期</th>
                            <th class="table-date am-hide-sm-only">创建日期</th>
                            <th>是否删除</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($datas as $data)
                        <tr>
                            <td><input type="checkbox"/></td>
                            <td>{{$data->id}}</td>
                            <td><a href="javascript:;">{{$data->name}}</a></td>
                            <td>{{$data->comName}}</td>
                            <td class="am-hide-sm-only">{{$data->periodTime}}</td>
                            <td class="am-hide-sm-only">{{$data->createTime}}</td>
                            <td>
                                @if($data->del)
                                    <span style="color:red;">已删除</span>
                                @else 使用中
                                @endif
                            </td>
                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <a href="{{$prefix_url}}/{{$data->id}}/edit">
                                            <button class="am-btn am-btn-default
                                                am-btn-xs am-text-secondary">
                                                <span class="am-icon-pencil-square-o"></span>
                                                编辑
                                            </button>
                                        </a>
                                        @if(!$data->del)
                                        <a href="javascript:;"
                                           onclick="getDel({{$data->id}})">
                                            <button class="am-btn am-btn-default
                                            am-btn-xs am-text-danger
                                            am-hide-sm-only">
                                                <span class="am-icon-trash"></span>
                                                删除
                                            </button>
                                        </a>
                                        @endif
                                    </div>
                                </div>
                            </td>
                        </tr>
                        @endforeach
                        </tbody>
                    </table>
                    @include('admin.layouts.page')
                </div>
            </div>
        </div>
    </div>

    <div class="am-modal am-modal-alert" tabindex="-1" id="alertPop">
        <div class="am-modal-dialog">
            <div class="am-modal-bd">
                确定要删除么？
                <input type="hidden" id="delId" value="0">
            </div>
            <div class="am-modal-footer">
                <span class="am-modal-btn">关闭</span>
                <button type="submit" onclick="setDel()"
                        style="color:#0088cc;cursor:pointer;
                            padding:10px 0;width:100%;border:0;background:0;">
                    确定删除
                </button>
            </div>
            </form>
        </div>
    </div>

    <script type="text/javascript">
        //删除提醒
        function getDel(id){
            $('#delId')[0].value = id;
//            console.log(id); return
            $('#alertPop').modal();
        }
        //设置删除
        function setDel(){
            var id = $('#delId').val();
            window.location.href = '{{$prefix_url}}/del?id='+id;
        }
    </script>
@stop